<?php
// 本类由系统自动生成，仅供测试用途
header('content-type:text/html;charset=utf-8');
class IndexAction extends Action {
    public function index(){
		if(isset($_SESSION['username'])&&$_SESSION['uid']!=''){
			$this->display();
		}else{
			$this->redirect('login','',2,'你没有登录，请先登录！');
		}
    }
	public function cklogin(){
		if($this->isPOST()){
			$m=M('Admin');
			$where['username']=$_POST['username'];
			$arr=$m->find(1);
			if($arr['username']==$_POST['username']&&md5($_POST['password'])==$arr['password']){
				$_SESSION['username']=$_POST['username'];
				$_SESSION['uid']=$arr['id'];
				$_SESSION['password']=$arr['password'];
				$this->success('登录成功','index');
			}else{
				$this->error('登录失败');
			}
		}
	}

	public function loginout(){
		if(isset($_SESSION['uid'])){
			unset($_SESSION['usename']);
			unset($_SESSION['password']);
			unset($_SESSION['uid']);
			$this->redirect('login');
		}
	}
}